import { getReportHistory } from '@/api/record'
import { REPORT_REPORT } from '@/config'

export default {
  data () {
    return {
      loading: false,
      lists: [],
      pagination: {
        pageNumber: 1,
        pageSize: 5,
        total: 0,
      }
    }
  },
  computed: {
    themeColor () {
      return this.$store.state.user.theme
    }
  },
  methods: {
    /**
     *
     * @param {{
     * year: string | number
    * quarter: string | number
    * tableId: string | number
    * pageNumber: number
    * pageSize: number
    * tenantId: string | number
    * eventType: string | number
    * }} params
    * @returns
    */
    async getLists (params) {
      this.loading = true
      try {
        const { data = {} } = await getReportHistory(params)
        this.lists = (data.records || []).map(v => ({
          name: (REPORT_REPORT[v.tableId] || {}).alias,
          time: v.creationTime,
          type: v.eventType,
          user: v.creationName,
          remark: v.mark,
        }));
        this.pagination.total = data.total || 0;
      } finally {
        this.loading = false
      }
    },
  },
}
